Basic display objects


In [1]:
from IPython.display import display, Image, HTML, Javascript

Try using the basic display classes in a notebook:

  • Find an image on the internet and display it in a notebook using the Image class. You can either save the image in the notebook's directory or load it by its URL.
  • Use the HTML class and the %%html cell magic to display a snippet of HTML.
  • Use the JavaScript class and the %%javascript cell magic to run a snippet of JavaScript.
  • Try displaying these objects by both returning them from an expression and by passing them to display.

SoundCloud

Go to SoundCloud and search for a sound clip you want to embed in your notebook. To find the HTML code to embed the sound, click on the "Share" link and copy the "Embed" URL. Paste it into a cell using the %%html magic.


In [2]:
%load soln/soundcloud.ipy

Rich output on nbviewer

Rich output is also supported on http://nbviewer.ipython.org. To test this create a new notebook that has different types of rich output:

  • HTML
  • JPEG/PNG (use matplotlib)
  • JavaScript
  • LaTeX

After creating this notebook, upload it to http://gist.github.com and then view the notebook on http://nbviewer.ipython.org.